//导入axios请求工具
import request from '@/utils/request'
import { useTokenStore } from '@/stores/token'
//文章分类列表查询
export const articleCategoryListServie = () => {
    //获取token
    // const tokenStore = useTokenStore();
    //把token添加到请求头中（由于使用的pinia所以不需要使用.value就可以负值）
    // console.log(tokenStore.token);
    // return request.get('/category', { headers: { 'Authorization': tokenStore.token } })
    return request.get('/category')
}

//添加文章分类接口
export const articleCategoryAddService = (categoryData) => {
    return request.post('/category', categoryData)
}

//编辑文章分类接口
export const articleCategoryEditService = (categoryData) => {
    return request.put('/category', categoryData)
}

//删除文章分类接口
export const articleCategoryDeleteService = (categoryId) => {
    return request.delete(`/category?id=${categoryId}`);
}

//获取文章列表接口
export const articleListService = (params) => {
    return request.get('/article', { params: params })
}

//添加文章相关接口
export const articleAddService = (articleData) => {
    return request.post('/article', articleData)
}

//修改文章接口
export const articleEditService = (articleData) => {
    return request.put('/article', articleData)
}

//删除文章接口
export const articleDeleteService = (articleId) => {
    return request.delete(`/article?id=${articleId}`)
}